// 'use strict';

let
    Koa = require('koa'),
    bodyParser = require('koa-bodyparser'),
    app = new Koa(),
    port = 7777,
    njkMiddleWare = require('./tempMiddleWare'),
    router = require('koa-router')(),
    controllers = require('./controllers'),
    fs = require('fs'),
    static = require('koa-static');



app.use(bodyParser());

app.use(njkMiddleWare);

app.use(controllers());

app.use(static('.'));

app.use(static(__dirname + '/static'));

router.get('/', ctx => {
    ctx.response.file = 'html';
    ctx.response.body = fs.createReadStream(__dirname + '/static/Flowers.html')
})


// router.get('/', async (ctx, next) => {
//     await ctx.render('forin.html', {
//         username: 'GiGi',
//         num: 5,
//         userArr: [
//             { id: 1, name: 'GiGi', age: 20 },
//             { id: 2, name: 'Curry', age: 32 },
//             { id: 3, name: 'Bluss', age: 40 },
//             { id: 4, name: 'David', age: 52 },
//         ],
//         str: 'hello world'
//     });
//     next();
// })

app.use(router.routes());

app.listen(port);

console.log(`http://localhost:${port}`);